<?php

namespace app\index\controller;

require_once PUBLIC_PATH."/bar/php/php-barcode.php";
require_once PUBLIC_PATH."/qrcode/phpqrcode/phpqrcode.php";

use QRcode;
use think\Controller;

class Bar extends Controller
{
   public function index()
   {
       return view("index");
   }
   public function phpbar()
   {
       $im     = imagecreatetruecolor(300, 110);
       $black  = ImageColorAllocate($im,0x00,0x00,0x00);
       $white  = ImageColorAllocate($im,0xff,0xff,0xff);
       imagefilledrectangle($im, 0, 0, 300, 300, $white);
       $data = \Barcode::gd($im, $black, 150, 55, 0, "code128", "1234567", 3, 80);
//       header('Content-type: image/gif');
       $imgPath = PUBLIC_PATH."/phpbar/";
       file_exists($imgPath) or mkdir($imgPath);
       $imgPath.="phpbarcode.jpg";
       imagegif($im,$imgPath);
       imagedestroy($im);
       return view("php",compact('imgPath'));
   }

   public function jqueryQrCode()
   {
       return view("jqueryqrcode");
   }

   public function phpQrCode()
   {
       $dir = "imgs/";
       file_exists($dir) or mkdir($dir,0755);
       $imagePath = $dir."test.jpg";
       QrCode::png("123456789",$imagePath,QR_ECLEVEL_L,5,2,false);
       return view("phpqrcode",compact('imagePath'));
   }

}